package com.ruoyi.apiserver.controller;

import com.ruoyi.apiserver.services.ReportGenerationProducerService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 报告生成测试控制器
 */
@RestController
@RequestMapping("/api/report")
public class ReportTestController {
    
    @Autowired
    private ReportGenerationProducerService reportGenerationProducerService;
    
    /**
     * 测试发送报告生成请求
     * @param outTradeNo 订单号
     * @param userId 用户ID
     * @return 结果
     */
    @PostMapping("/generate")
    public AjaxResult testGenerateReport(@RequestParam String outTradeNo, @RequestParam Long userId) {
        try {
            // 发送报告生成请求到消息队列
            reportGenerationProducerService.sendReportGenerationRequest(outTradeNo, userId);
            return AjaxResult.success("报告生成请求已发送到消息队列");
        } catch (Exception e) {
            return AjaxResult.error("发送报告生成请求失败: " + e.getMessage());
        }
    }
}